package com.qth.valet.mapper;

import com.qth.valet.entity.po.DriverBalanceDetail;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.qth.valet.entity.vo.IncomesVo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * @author 蔡徐坤
 * @since 2025-09-15
 */
public interface DriverBalanceDetailMapper extends BaseMapper<DriverBalanceDetail> {
    /*@Select("SELECT\n" +
            "\tsum(d1.amount) todayIncome,\n" +
            "\tsum(d2.amount) monthIncome,\n" +
            "\tsum(d3.amount) totalWithdraw,\n" +
            "\tsum(d4.amount) totalIncome\n" +
            "FROM\n" +
            "\tdriver_balance_detail d\n" +
            "LEFT JOIN driver_balance_detail d1 ON d.id = d1.id\n" +
            "AND date(d1.create_time) = CURDATE()\n" +
            "AND d1.balance_type = 1\n" +
            "LEFT JOIN driver_balance_detail d2 ON d.id = d2.id\n" +
            "AND DATE_FORMAT(d2.create_time, '%Y%m') = DATE_FORMAT(CURDATE(), '%Y%m')\n" +
            "AND d2.balance_type = 1\n" +
            "LEFT JOIN driver_balance_detail d3 ON d.id = d3.id\n" +
            "AND d3.balance_type = 2\n" +
            "LEFT JOIN driver_balance_detail d4 ON d.id = d4.id\n" +
            "AND d4.balance_type = 1\n" +
            "WHERE\n" +
            "\td.driver_id = #{driverId};")*/
    IncomesVo getDriverIncomes(@Param("driverId") Integer driverId);
}
